package com.example.statisticsservice.controller;


import com.example.commonutils.R;
import com.example.statisticsservice.service.OrderStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2023-08-11
 */
@RestController
@RequestMapping("/statisticsservice/statistics")
public class OrderStatisticsController {
    @Autowired
    private OrderStatisticsService statisticsService;
    //生成统计数据
    @PutMapping("/createStatics/{date}")
    public R createStatistics(@PathVariable String date){
        statisticsService.createData(date);
        return R.ok();
    }
    //图表显示
    @GetMapping("showData/{type}/{begin}/{end}")
    public R showData(@PathVariable String type, @PathVariable String begin, @PathVariable String end){
        Map<String,Object> map = statisticsService.getShowData(type,begin,end);
        return R.ok().data(map);
    }
}

